package org.vsaulyak.springrssagregator.bean;

import java.util.List;
import javax.inject.Inject;
import org.springframework.stereotype.Component;
import org.vsaulyak.springrssagregator.entity.Chanel;
import org.vsaulyak.springrssagregator.dao.ChanelDao;
import org.vsaulyak.springrssagregator.exception.AppropriateParserNotFoundException;

@Component
public class ParseScheduller 
{
    @Inject
    ChanelDao chanelDao;
    
    @Inject
    ChanelHandler chanelHandler;
    
    public void parseNewItems()
    {
        System.out.println(" -- Cron");
        List<Chanel> chanels = chanelDao.getChanels();
        for (Chanel chanel : chanels)
        {
            try
            {
                chanelHandler.parseItems(chanel);
            }
            catch (AppropriateParserNotFoundException e)
            {
                //TODO
                System.out.println(" -- AppropriateParserNotFoundException");
            }
        }
    }
}
